import { request } from '@/utils/request';
import { RoleList, AddRoleParams } from '@/api/model/system/roleModel';
const Api = {
  list: '/system/role/list',
  post: '/system/role',
  Info: '/system/role/',
  put: '/system/role',
  delete: '/system/role/',
  menuTreeselect: '/system/menu/treeselect',
  roleMenuTreeselect: '/system/menu/roleMenuTreeselect/',
};

// 查询菜单下拉树结构
export function menuTreeselect() {
  return request.get({
    url: Api.menuTreeselect,
  });
}

// 根据角色ID查询菜单下拉树结构
export function roleMenuTreeselect(roleId: string | number) {
  return request.get({
    url: Api.roleMenuTreeselect + roleId,
  });
}

// 角色列表
export function getList(params: RoleList) {
  return request.get({
    url: Api.list,
    params,
  });
}

// 新增角色
export function add(data: AddRoleParams) {
  return request.post({
    url: Api.post,
    data,
  });
}

// 角色详情
export function getInfo(userId: string | number) {
  return request.get({
    url: Api.Info + userId,
  });
}

// 编辑角色
export function edit(data: AddRoleParams) {
  return request.put({
    url: Api.put,
    data,
  });
}

// 删除角色
export function Delete(ids: string) {
  return request.delete({
    url: Api.Info + ids,
  });
}
